package my.jwds.p125;

import my.jwds.p101.IsSymmetric;

public class IsPalindrome {
    public static void main(String[] args) {
        IsPalindrome o = new IsPalindrome();
        System.out.println(o.isPalindrome("ab2a"));
    }
    public boolean isPalindrome(String s) {
        int l=0,r=s.length()-1;
        while (l < r){
            char lchar = s.charAt(l);
            while((lchar< 65 || lchar > 90) && (lchar<97 || lchar > 122) && (lchar <48 || lchar > 57) && l < r){
                lchar = s.charAt(++l);
            }
            char rchar = s.charAt(r);
            while((rchar< 65 || rchar > 90) && (rchar<97 || rchar > 122)&& (rchar <48 || rchar > 57) && l < r){
                rchar = s.charAt(--r);
            }
            if ((lchar < 48 || lchar > 57) && (rchar < 48 || rchar > 57)){
                if (lchar != rchar && (lchar - rchar)*(lchar - rchar) != 32*32)return false;
            }else{
                if (lchar != rchar)return false;
            }
            l++;
            r--;
        }
        return true;
    }
}
